package com.kly.user.db.dao.impl;
import com.fqgj.common.base.AbstractBaseMapper;
import com.google.common.collect.Maps;
import com.kly.user.db.dao.UserPromotionRecordDao;
import com.kly.user.db.entity.UserPromotionRecordEntity;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
* User: user
* Date: 2024-01-25
* Time: 14:13:29.276
*/

@Repository
public class UserPromotionRecordDaoImpl extends AbstractBaseMapper<UserPromotionRecordEntity> implements UserPromotionRecordDao {

    @Override
    public int queryCountByPromotionType(String userCode, Integer promotionType) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("promotionType", promotionType);
        return this.getSqlSession().selectOne(this.getStatement("queryCountByPromotionType"), params);
    }

    @Override
    public UserPromotionRecordEntity getLastByUserCode(String userCode) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        return this.getSqlSession().selectOne(this.getStatement("getLastByUserCode"), params);
    }

    @Override
    public UserPromotionRecordEntity getUserPromotion(String userCode) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        return this.getSqlSession().selectOne(this.getStatement("getUserPromotion"), params);
    }

    @Override
    public Integer getUserPromotionCount(String userCode) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        return (Integer)this.getSqlSession().selectOne(this.getStatement("getUserPromotionCount"), params);
    }
}